package com.boot.dto;

import lombok.Data;
import org.camunda.bpm.engine.task.Task;

import java.util.Date;

@Data
public class TaskDto {
    private String id;
    private String name;
    private String assignee;
    private String owner;
    private String description;
    private int priority;
    private Date createTime;
    private Date dueDate;
    private String parentTaskId;
    private String executionId;
    private String processInstanceId;
    private String processDefinitionId;
    private boolean suspended;
    private String taskDefinitionKey;

    public static TaskDto from(Task task) {
        TaskDto dto = new TaskDto();
        dto.setId(task.getId());
        dto.setName(task.getName());
        dto.setAssignee(task.getAssignee());
        dto.setOwner(task.getOwner());
        dto.setDescription(task.getDescription());
        dto.setPriority(task.getPriority());
        dto.setCreateTime(task.getCreateTime());
        dto.setDueDate(task.getDueDate());
        dto.setParentTaskId(task.getParentTaskId());
        dto.setExecutionId(task.getExecutionId());
        dto.setProcessInstanceId(task.getProcessInstanceId());
        dto.setProcessDefinitionId(task.getProcessDefinitionId());
        dto.setSuspended(task.isSuspended());
        dto.setTaskDefinitionKey(task.getTaskDefinitionKey());
        return dto;
    }
}
